class Solution(object):
    def maxProduct(self, words):
        """
        :type words: List[str]
        :rtype: int
        """
        n = len(words)
        w = [set(words[i]) for i in range(n)]
        length = [len(words[i]) for i in range(n)]
        max_length = 0
        for i in range(n):
            for j in range(i + 1, n):
                if not w[i] & w[j]:
                    max_length = max(max_length, length[i] * length[j])
        return max_length



data = Solution()
words = ["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]
print(data.maxProduct(words))
